package com.zzyl.nursing.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzyl.common.utils.UserThreadLocal;
import com.zzyl.nursing.domain.FamilyMemberElder;
import com.zzyl.nursing.mapper.FamilyMemberElderMapper;
import com.zzyl.nursing.service.IFamilyMemberElderService;
import org.springframework.stereotype.Service;

/**
 * 家属老人中间Service业务层处理
 *
 * @author alexis
 * @date 2025-06-06
 */
@Service
public class FamilyMemberElderServiceImpl extends ServiceImpl<FamilyMemberElderMapper, FamilyMemberElder> implements IFamilyMemberElderService {

    /**
     * 解绑老人
     *
     * @param elderId 老人id
     */
    @Override
    public void handleUnbind(Long elderId) {
        Long userId = UserThreadLocal.getUserId();
        lambdaUpdate().eq(FamilyMemberElder::getElderId, elderId).eq(FamilyMemberElder::getFamilyMemberId, userId)
                      .remove();
    }
}
